package cn.hss.thread;

/**
 * @author 作者：HeShaoShuai
 * @Email 邮箱：2569819541@qq.com
 * @Date 日期：2023/4/28 14:29
 * @Package 包名：cn.hss.thread
 * @Project 项目名：JavaSE
 * @Version 1.0
 */
public class SaleTicketDemo {
	public static void main(String[] args) {
		Window w1 = new Window("窗口1");
		Window w2 = new Window("窗口2");
		Window w3 = new Window("窗口3");
		//启动线程，开始售票
		w1.start();
		w2.start();
		w3.start();
	}
}
//模拟售票窗口
class Window extends Thread{
	private static int ticket=100;
	public Window(String name){
		super(name);
	}
	@Override
	public void run() {
		while(ticket>0){
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(getName()+
					"卖出一张票，票号："+ticket);
			ticket--;
		}
	}
}